/**
 */
package org.aphelie.chronicle.character.impl;

import org.aphelie.chronicle.character.ArcCharacter;
import org.aphelie.chronicle.character.Capacities;
import org.aphelie.chronicle.character.CharacterPackage;
import org.aphelie.chronicle.character.Traits;
import org.aphelie.chronicle.impl.ArcTopicImpl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Arc Character</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.aphelie.chronicle.character.impl.ArcCharacterImpl#getTraits <em>Traits</em>}</li>
 *   <li>{@link org.aphelie.chronicle.character.impl.ArcCharacterImpl#getCapacities <em>Capacities</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class ArcCharacterImpl extends ArcTopicImpl implements ArcCharacter {
	/**
	 * The cached value of the '{@link #getTraits() <em>Traits</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTraits()
	 * @generated
	 * @ordered
	 */
	protected Traits traits;
	/**
	 * The cached value of the '{@link #getCapacities() <em>Capacities</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCapacities()
	 * @generated
	 * @ordered
	 */
	protected Capacities capacities;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ArcCharacterImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CharacterPackage.Literals.ARC_CHARACTER;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Traits getTraits() {
		return traits;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetTraits(Traits newTraits, NotificationChain msgs) {
		Traits oldTraits = traits;
		traits = newTraits;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CharacterPackage.ARC_CHARACTER__TRAITS, oldTraits, newTraits);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTraits(Traits newTraits) {
		if (newTraits != traits) {
			NotificationChain msgs = null;
			if (traits != null)
				msgs = ((InternalEObject)traits).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CharacterPackage.ARC_CHARACTER__TRAITS, null, msgs);
			if (newTraits != null)
				msgs = ((InternalEObject)newTraits).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CharacterPackage.ARC_CHARACTER__TRAITS, null, msgs);
			msgs = basicSetTraits(newTraits, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CharacterPackage.ARC_CHARACTER__TRAITS, newTraits, newTraits));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Capacities getCapacities() {
		return capacities;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetCapacities(Capacities newCapacities, NotificationChain msgs) {
		Capacities oldCapacities = capacities;
		capacities = newCapacities;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CharacterPackage.ARC_CHARACTER__CAPACITIES, oldCapacities, newCapacities);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCapacities(Capacities newCapacities) {
		if (newCapacities != capacities) {
			NotificationChain msgs = null;
			if (capacities != null)
				msgs = ((InternalEObject)capacities).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CharacterPackage.ARC_CHARACTER__CAPACITIES, null, msgs);
			if (newCapacities != null)
				msgs = ((InternalEObject)newCapacities).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CharacterPackage.ARC_CHARACTER__CAPACITIES, null, msgs);
			msgs = basicSetCapacities(newCapacities, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CharacterPackage.ARC_CHARACTER__CAPACITIES, newCapacities, newCapacities));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CharacterPackage.ARC_CHARACTER__TRAITS:
				return basicSetTraits(null, msgs);
			case CharacterPackage.ARC_CHARACTER__CAPACITIES:
				return basicSetCapacities(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CharacterPackage.ARC_CHARACTER__TRAITS:
				return getTraits();
			case CharacterPackage.ARC_CHARACTER__CAPACITIES:
				return getCapacities();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CharacterPackage.ARC_CHARACTER__TRAITS:
				setTraits((Traits)newValue);
				return;
			case CharacterPackage.ARC_CHARACTER__CAPACITIES:
				setCapacities((Capacities)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case CharacterPackage.ARC_CHARACTER__TRAITS:
				setTraits((Traits)null);
				return;
			case CharacterPackage.ARC_CHARACTER__CAPACITIES:
				setCapacities((Capacities)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CharacterPackage.ARC_CHARACTER__TRAITS:
				return traits != null;
			case CharacterPackage.ARC_CHARACTER__CAPACITIES:
				return capacities != null;
		}
		return super.eIsSet(featureID);
	}

} //ArcCharacterImpl
